Skip to main content

Development Environment

Overview

Here is a brief overview of the development setup.

System Requirements

Dev Computer

  • Hardware

    1. PC running on Windows
  • Operating System

    1. Windows 11 (64-bit)
  • Software

    1. Apache NetBeans IDE 17
    2. Java Runtime Environment v17
    3. VSCode (1.78.2, latest should also work)
    4. Tera Term (v4.106, latest should also work)

901C Machine

  • Hardware

    1. 901C machine which contains a R-Pi v3 (32-bit) using a 32GB SD card.
    2. Or if the code is being developed for R-Pi v4, a R-Pi v4 (64bit) board with 32GB SD card.
  • Operating System

    1. R-Pi Raspbian Version 9 (Stretch)
  • Software

    1. Apache NetBeans IDE 17
    2. Java Runtime Environment v17
    3. VSCode (1.78.2, latest should also work)
    4. Tera Term (v4.106, latest should also work)

Installation

NetBeans setup

This requires netbeans with C++ support plugin installed. Since newest Apache NetBeans release (version 17) didn't support the C++ plugin directly, some workaround were needed. Following notes are for Windows 11

  1. Installed the latest Netbeans (version 17) to default location.
  2. Installed latest JDK (version 17)
  3. Download JDK 13 binary files from https://jdk.java.net/java-se-ri/13 and extract the content.
  4. Search for unpack200.exe in the extracted JDK13 folder. (It should be located inside the bin directory)
  5. Copy the file to the bin directory in the install location of JDK latest version (version 17 for me. JDK was located in C:\ProgramFiles\Java\jdk-17\) (The need for this is found here)
  6. Then install the C++ plugins for netbeans following the answer here

VSCode

  1. VSCode is used in-conjunction with NetBeans for the code-development.

Tera Term

  1. Tera Term is used to SSH into the R-Pi of the 901C machine to do terminal based operations.

Project Repositories

  1. AgPoint-901C Code for the R-Pi 3B
    1. v1.5_cleanup Cleaned up code containing the changes I made to the carousal logic built on top of code-from-Alan
    2. code-from-Alan Zipped code base received from Alan
    3. 09132018 Code with version tag v2.0 found from the R-Pi image Alan shared
    4. code-from-pi Code found from the R-Pi image that seems to have generated the default binary
    5. code-from-pi-v2 Code with version tag v2.0 from R-Pi image (not sure what is the difference between this and 09132018)
    6. mdhippj_Ronc6F Code with origin 192.168.0.188 mdhippj Ronc6 from R-Pi image
    7. mdhippj_Ronc6 Code with origin Code from 192.168.0.188 mdhippj 'last one' from R-Pi image. Note that this has references to an older version of QT Interface Compiler, from v4.8.x to 4.6.
    8. main Not sure which version is considered as main now. This should be changed to reflect v1.5_cleanup after reviewing.
  2. AgPoint-901C-2023 The updated code for R-Pi 4 modified from AgPoint-901C code-from-Alan.
    1. main This branch contains the respective code.
  3. AgPoint-Tasks A repo created to track the tasks related to AgPoint. No code is present.

Configuration

NetBeans

  1. Power on the R-Pi (by powering on the 901C machine)
  2. Get the R-Pi connected to the same network as of your machine.
    1. If you are starting from a clean R-Pi installation, use the GUI to connect to the WiFi.
    2. Or if you are using 901C machine directly, use the connect to network option available in the 901C application itself. Check the 901C manual for instructions.
  3. Launch NetBeans. Due to the workaround we used it will prompt the following message. Click Yes. invalid java path
  4. Open the project from File menu.
  5. Goto Run Set Project Configuration Customize. customize menu
  6. Add the ip address of the R-Pi using the following menu entries.
    1. Goto the the Add window. add ip address
    2. Give the ip address of the R-Pi and click Nextip address
    3. Give the credentials to the R-Pi, by default, username is pi and password is raspberry. After setting up the credentials, click Next and finally OK on all windows. credentials
  7. Try Build command and if the configuration is done correctly, NetBeans should connect to the R-Pi and build the project there. Build or F11
    You should get an output like this:
    build output

Shell scripts on R-Pi

I have created the following scripts in the R-Pi to help the deployment and testing.

  1. Stop the current 901 binary that is being run in the attached touchscreen to the 901C machine. (~/stop_901C_and_refresh.sh)

    #!/bin/bash

    ( ps -e | grep 901 | cut -f 3 -d ' ' | xargs sudo kill ) &
    ( ps -e | grep 901 | cut -f 2 -d ' ' | xargs sudo kill ) &
    sleep 10
    cp .netbeans/remote/192.168.0.5/17-cn0065cl-2-Windows-x86_64/C/git/projects/AgPoint/AgPoint-901C/src/dist/Debug/GNU-Linux/src 901C
    note

    Update the first argument of the cp command above to point to thesrc file of your remote build directory.

  2. Script to launch the 901C binary and restart the SSH service in the background. This script is run from the touchscreen of the 901C machine itself. (~/start_901C.sh)

    #!/bin/bash
    sudo /home/pi/901C
    ( sleep 60 ; sudo service ssh restart ) &

Development workflow for R-Pi 3B

note

The active branch for the latest code changes is AgPoint-901C v1.5_cleanup

  1. Open the project through NetBeans and get the R-Pi up connected and setup for remote development with the instructions above.
  2. Develop the code through NetBeans (I also used VSCode at the same time for coding).
  3. Build the source through NetBeans. As NetBeans is already configured for remote development, the binary will be generated in the R-Pi at /home/pi/.netbeans/remote/192.168.0.5/17-cn0065cl-2-Windows-x86_64/C/git/projects/AgPoint/AgPoint-901C/src/dist/Debug/GNU-Linux/src where,
    1. 192.168.0.5 is the ip address of the R-Pi in my local network
    2. 17-cn0065cl-2-Windows-x86_64 is the hostname of my Windows PC where NetBeans reside.
    3. /C/git/projects/AgPoint/AgPoint-901C/ is the project directory in my Windows machine.
  4. Then using Tera Term, SSH into R-Pi and run ~/stop_901C_and_refresh.sh to stop the currently running process and update the binary with the newly built one of which details are mentioned here.
  5. From R-Pi touchscreen run ~/start_901C.sh to run the new binary.

Code changes

  1. By 6/14/2023 the changes made to the code only focused on getting the chute alignment logic right. A preliminary logic was implemented and tested which we refer to as chute alignment v1 in related files. A test video can be found here.

Development for R-Pi 4 latest

Upgrading to latest Raspbian and installing project dependencies

In the R-Pi (Raspbian Bullseye 32bit with desktop):

  1. Install Qt5

    sudo apt-get install qtbase5-dev qtchooser
    sudo apt-get install qt5-qmake qtbase5-dev-tools
    sudo apt-get install qtcreator
    sudo apt-get install qtdeclarative5-dev

    Find details of transitioning from Qt4 to Qt5 here

    Code changes:

    // #include <qt4/QtCore/qstring.h>
    #include <qt5/QtCore/qstring.h>

    // All imports from QtGui should change to QtWidgets. e.g.
    // #include <QtGui/qwidget.h>
    #include <QtWidgets/qwidget.h>

    // In Qt5, QApplication::UnicodeUTF8 is depricated. It is set to be the default
    // All function calls containing QApplication::UnicodeUTF8 is changed as following example
    // btnOK->setText(QApplication::translate("AboutScreen", "OK", 0, QApplication::UnicodeUTF8));
    btnOK->setText(QApplication::translate("AboutScreen", "OK", 0));

    // Qt4 to Qt5 change -> QHeaderView changes
    // widget.tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
    widget.tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

    // Following threw compiler errors. Hence had to be commented out. Need to find the cause
    // connect(widget.btn .btnCounterSetup, SIGNAL(pressed()), this, SLOT(DisplayCounterSetup()));//added0220

    // widget.btnCounterSetup->setStyleSheet("background-color:white;");// added0220
    // widget.btnCounterSetup->setText("Counter\nSETUP");// added0220

    Qt version: Qt version 5.15.2 in /usr/lib/arm-linux-gnueabihf

  2. Installing MYSQL

    -lmysqlclient

    is removed from the linker as I couldn't install the library in Raspbian. Instead the corresponding library for mariadb is linked.

    This needs to be changed from mysql to mariadb as MYSQL no longer support raspbian

    sudo apt install mariadb-server
    sudo apt install libmariadb-dev
    sudo apt install libmysqlcppconn-dev
    // #include </usr/include/mysql/mysql.h>
    #include </usr/include/mariadb/mysql.h>

    Installed version : mariadb Ver 15.1 Distrib 10.5.15-MariaDB, for debian-linux-gnueabihf (armv8l) using EditLine wrapper

  3. WiringPi

    The official support for the WirePi library has stopped. Installed it through an active fork.

    cd git/public
    git clone https://github.com/WiringPi/WiringPi.git
    cd WiringPi
    ./build
  4. Wireless library

    sudo apt-get install libiw-dev

Errors

While running the program in R-Pi v4 display backlight error